#include <stdio.h>
#include <stdlib.h>
#include <ctype.h>

#define BOARD 8

char piece, board[BOARD][BOARD], king;
int isEmpty, hasWinner, player, game, i, j, first=1;

void winner(char theWinner[10]);
int checkDiagonal(int x, int y);
int checkAxes(int x, int y);
int isKing(int x, int y);

int main(void){
#ifndef ONLINE_JUDGE
    freopen("in.txt", "r", stdin);
    freopen("out.txt", "w+", stdout);
#endif
    game = 0;
    first = 1;
    while(1){
        isEmpty = 1;
        for(j = 0; j < BOARD; j++){
            for(i = 0; i < BOARD; i++){
                while((piece = getchar()) == '\n')
                    ;
                if(piece != '.')
                    isEmpty = 0;
                board[i][j] = piece;
            }
        }
        if(first)
            first = 0;
        else
            printf("\n");
        if(isEmpty) break;
        hasWinner = 0;
        for(j = 0; j < BOARD && hasWinner == 0; j++){
            for(i = 0; i < BOARD && hasWinner == 0; i++){
                piece = board[i][j];
                if(piece == '.') continue;
                player = isupper(piece);
                piece = tolower(piece);
                king = player ? 'k' : 'K';
                if(piece == 'p'){
                    if(player){
                        if(i > 0 && j > 0){
                            if(board[i-1][j-1] == 'k'){
                                winner("black");
                                break;
                            }
                        }
                        if(i < BOARD-1 && j > 0){
                            if(board[i+1][j-1] == 'k'){
                                winner("black");
                                break;
                            }
                        }
                    }
                    else{
                        if(i > 0 && j < BOARD-1){
                            if(board[i-1][j+1] == 'K'){
                                winner("white");
                                break;
                            }
                        }
                        if(i < BOARD-1 && j < BOARD-1){
                            if(board[i+1][j+1] == 'K'){
                                winner("white");
                                break;
                            }
                        }
                    }
                }
                else if(piece == 'n'){
                    if(j > 1 && i > 0 && board[i-1][j-2] == king){
                        winner(player ? "black" : "white");
                        break;
                    }
                    if(j > 0 && i > 1 && board[i-2][j-1] == king){
                        winner(player ? "black" : "white");
                        break;
                    }
                    if(j < BOARD-1 && i > 1 && board[i-2][j+1] == king){
                        winner(player ? "black" : "white");
                        break;
                    }
                    if(j < BOARD-2 && i > 0 && board[i-1][j+2] == king){
                        winner(player ? "black" : "white");
                        break;
                    }
                    if(j < BOARD-2 && i < BOARD-1 && board[i+1][j+2] == king){
                        winner(player ? "black" : "white");
                        break;
                    }
                    if(j < BOARD-1 && i < BOARD-2 && board[i+2][j+1] == king){
                        winner(player ? "black" : "white");
                        break;
                    }
                    if(j > 1 && i < BOARD-1 && board[i+1][j-2] == king){
                        winner(player ? "black" : "white");
                        break;
                    }
                    if(j > 0 && i < BOARD-2 && board[i+2][j-1] == king){
                        winner(player ? "black" : "white");
                        break;
                    }
                }
                else if(piece == 'b'){
                    if(checkDiagonal(i, j)){
                        winner(player ? "black" : "white");
                        break;
                    }
                }
                else if(piece == 'r'){
                    if(checkAxes(i, j)){
                        winner(player ? "black" : "white");
                        break;
                    }
                }
                else if(piece == 'q'){
                    if(checkDiagonal(i, j) || checkAxes(i, j)){
                        winner(player ? "black" : "white");
                        break;
                    }
                }
            }
        }
        if(!hasWinner)
            winner("no");
    }
    return(0);
}

int checkDiagonal(int x, int y){
    int x1, y1;
    x1 = x;
    y1 = y;
    while(x1 > 0 && y1 > 0 && board[--x1][--y1] == '.')
        ;
    if(isKing(x1, y1))
        return 1;
    x1 = x;
    y1 = y;
    while(x1 > 0 && y1 < BOARD-1 && board[--x1][++y1] == '.')
        ;
    if(isKing(x1, y1))
        return 1;
    x1 = x;
    y1 = y;
    while(x1 < BOARD-1 && y1 < BOARD-1 && board[++x1][++y1] == '.')
        ;
    if(isKing(x1, y1))
        return 1;
    x1 = x;
    y1 = y;
    while(x1 < BOARD-1 && y1 > 0 && board[++x1][--y1] == '.')
        ;
    if(isKing(x1, y1))
        return 1;
    return 0;
}

int checkAxes(int x, int y){
    int x1, y1;
    x1 = x;
    while(x1 > 0 && board[--x1][y] == '.')
        ;
    if(isKing(x1, y))
        return(1);
    x1 = x;
    while(x1 < BOARD-1 && board[++x1][y] == '.')
        ;
    if(isKing(x1, y))
        return(1);
    y1 = y;
    while(y1 > 0 && board[x][--y1] == '.')
        ;
    if(isKing(x, y1))
        return(1);
    y1 = y;
    while(y1 < BOARD-1 && board[x][++y1] == '.')
        ;
    if(isKing(x, y1))
        return(1);
    return(0);
}

int isKing(int x, int y){
    if(board[x][y]==king)
        return(1);
    return(0);
}

void winner(char theWinner[10]){
    game++;
    hasWinner = 1;
    printf("Game #%d: %s king is in check.", game, theWinner);
}

